// Copyright (c) MatrixFramework. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;
using System;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.Autofac;
using Volo.Abp.Modularity;

namespace PhotoGalleryService.HttpApi.Host;

/// <summary>
/// 程序启动类
/// </summary>
public class Program
{
    public static int Main(string[] args)
    {
        try
        {
            Log.Information("Starting PhotoGalleryService.HttpApi.Host.");
            var builder = WebApplication.CreateBuilder(args);
            builder.Host
                .UseAutofac()
                .UseSerilog();

            builder.Services.AddApplication<PhotoGalleryServiceHttpApiHostModule>();

            var app = builder.Build();
            app.InitializeApplication();
            app.Run();
            return 0;
        }
        catch (Exception ex)
        {
            Log.Fatal(ex, "PhotoGalleryService.Host terminated unexpectedly!");
            return 1;
        }
        finally
        {
            Log.CloseAndFlush();
        }
    }
}